import { useState, useEffect } from "react";
function App(){
   const [count, setCount] = useState(0)
   const [num, setNum] = useState('100')
    
    const add = ()=>{
        
        setCount(count+1)
        setNum(num+1)
    }

    useEffect(()=>{
        // const timer = setInterval(()=>{
        //     setCount(count+1)
        // },1000)
        return ()=>{
            console.log('卸载了');
            
        }
        console.log('useEffect')
    },[count,num])//不论页面更不更新，只要count或者num发生变化，就会执行useEffect

    

    return (
        <button onClick={add}>{count}</button>
    )
}

export default App;